package TrafficSim;

import javax.vecmath.Vector2d;

public class TrafficLightTest {

	public static void main(String[] args) throws InterruptedException{
		
		TrafficLightController ctrl;
		
		Intersection i = new Intersection(0, 0, 0);
		new Intersection(4, -5, 0).appendStreet(i,new Street(50, "Street1 "));
		new Intersection(3, 5, 0).appendStreet(i,new Street(50, "Street2 "));
		new Intersection(2, 0, -5).appendStreet(i, new Street(50, "Street3 "));
		new Intersection(1, 0, 5).appendStreet(i, new Street(50, "Street4 "));
		i.sort();
		i.addTrafficLightController();
		ctrl = i.getTLC();
		
		Vector2d vec1 = null;
		Vector2d vec2 = null;
		vec1 = new Vector2d(i.getIncomingStreets().get(0).getDirection());
		for (int j = 1; j < i.getIncomingStreets().size(); j++){
			vec2 = new Vector2d(i.getIncomingStreets().get(j).getDirection());
			if (vec1.angle(vec2) > 2.3){
				System.out.println(i.getIncomingStreets().get(j).toString()+ ": " + vec1.angle(vec2));
				System.out.println(i.getIncomingStreets().get(j) + ": eins");
			} else {
				System.out.println(i.getIncomingStreets().get(j).toString()+ ": " + vec1.angle(vec2));
				System.out.println(i.getIncomingStreets().get(j) + ": zwei");
			}
		}
		
		while(true){
//			ctrl.turnOn();
//			Thread.sleep(5000);
//			ctrl.toggleOn();
//			Thread.sleep(5000);
//			ctrl.switchState();
//			Thread.sleep(5000);
//			ctrl.switchState();
//			Thread.sleep(5000);
//			ctrl.toggleOff();
//			Thread.sleep(5000);
//			ctrl.turnOff();
//			Thread.sleep(3000);
		}
		
	}
}
